home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mebbs / craps30.lha / Craps.rexx < prev   
OS/2 REXX Batch file  |  1994-08-06  |  13KB  |  454 lines

  1. /***************************************************/
  2. /* $VER: Craps 3.00                                */
  3. /* $Filename: Craps.rexx $                         */
  4. /* $Version: 3.00 $                                */
  5. /* $Creation: 31.1.94 $                            */
  6. /***************************************************/
  7. /* Copyright 1994 Mikael Johansson [M6005] */
  8. /*******************************************/
  9.  
  10. parse arg LineNumber
  11. SIGNAL ON ERROR
  12.  
  13. options results      
  14. DoorName = "Craps"
  15.  
  16. if( ~show( 'l', "mebbsarexx.library" ) )then do
  17.    say "Opening mebbsarexx.library"
  18.     if( ~addlib( "mebbsarexx.library", 0, -30, 0 ) )then do
  19.       say "Could not open library"
  20.       exit 10
  21.    end
  22. end
  23.  
  24. Dir = "Doors:Craps/"
  25. playerfile = dir || "Craps.play"
  26.  
  27. Maxplayers = 100
  28.  
  29. if ~EXISTS(dir'Craps.CFG') then do
  30.   say "ERROR: Need Craps.CFG in "||dir
  31.   say "See Update.ReadMe how to create it"
  32.   exit
  33. end
  34.  
  35. call open file, (dir'Craps.CFG'), 'R'
  36.      line = readln(file)
  37.      parse var line BBSname=result
  38.      line = readln(file)
  39.      parse var line Sysopname=result
  40. call close file
  41.  
  42. call GetVar DoorName,LineNumber,1
  43. handle = result
  44. handle=TRANSLATE(handle,"_"," ")
  45. call GetVar DoorName,LineNumber,8
  46. ansi = result
  47.  
  48. name=handle
  49. uhandle=handle
  50. udate = date(N)
  51. CLS = 'H'
  52.    ROD    =''
  53.    GRON   =''
  54.    GUL    =''
  55.    BLA    =''
  56.    LILA   =''
  57.    CYAN   =''
  58.    VIT    =''
  59.    SVART2 =''
  60.    BLA2   =''
  61.    CYAN2  =''
  62.    normal = ''
  63. CR='0D'x
  64.  
  65. d.1.1 = LILA"   "CYAN
  66. d.2.1 = LILA" * "CYAN
  67. d.3.1 = LILA"   "CYAN
  68. d.1.2 = LILA"  *"CYAN
  69. d.2.2 = LILA"   "CYAN
  70. d.3.2 = LILA"*  "CYAN
  71. d.1.3 = LILA"  *"CYAN
  72. d.2.3 = LILA" * "CYAN
  73. d.3.3 = LILA"*  "CYAN
  74. d.1.4 = LILA"* *"CYAN
  75. d.2.4 = LILA"   "CYAN
  76. d.3.4 = LILA"* *"CYAN
  77. d.1.5 = LILA"* *"CYAN
  78. d.2.5 = LILA" * "CYAN
  79. d.3.5 = LILA"* *"CYAN
  80. d.1.6 = LILA"* *"CYAN
  81. d.2.6 = LILA"* *"CYAN
  82. d.3.6 = LILA"* *"CYAN
  83.  
  84. CALL BEGIN
  85. CALL INSTRUCTION
  86.  
  87. START:
  88.  
  89. string= ""VIT
  90. call output ; call Prompt DoorName,LineNumber," Wich number would you like to bet on (2-12) (Q = Quit) ? "||LILA||"",3
  91.     nub = result
  92.     CALL CHECKPANIC nub
  93.     if nub = "Q" then call BYE
  94.     if nub = "q" then call BYE
  95.     if nub < 1 | nub > 12 then do
  96.        string="B"
  97.        call output ; string=LILA||"Invalid number.  Try again!"||GUL||"" ; call output
  98.        CALL START
  99.     end
  100.  
  101.     string=""VIT ; call output
  102.     call Prompt DoorName,LineNumber," and how much would you like to bet? "||LILA||"",4
  103.     bet = result
  104.     CALL CHECKPANIC bet
  105.     if Bet > AcctBal then do
  106.          string="B" ; call output
  107.          string=VIT"You can not bet more than your account balance of:  $"AcctBal". Try Again!" ; call output
  108.          CALL START
  109.        end 
  110.        else if Bet > 1000 then do
  111.          string=VIT"You can not bet more $1,000. Try Again!" ; call output
  112.          CALL START
  113.        end
  114.  
  115. CALL ROLL(6)
  116. total = die1 + die2
  117. string=VIT"Total rolled is:"||LILA||total||VIT ; call output
  118. string="" ; call output
  119.  
  120. if total = nub & total = 7 then
  121. do
  122. abet = bet * 10
  123. acctbal = acctbal + abet
  124. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  125. end
  126.  
  127. if total = nub & total = 2 then
  128. do
  129. abet = bet + bet
  130. acctbal = acctbal + abet
  131. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  132. end
  133.  
  134. if total = nub & total = 3 then
  135. do
  136. abet = bet + bet
  137. acctbal = acctbal + abet
  138. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  139. end
  140.  
  141. if total = nub & total = 4 then
  142. do
  143. abet = bet + bet
  144. acctbal = acctbal + abet
  145. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  146. end
  147.  
  148. if total = nub & total = 5 then
  149. do
  150. abet = bet + bet
  151. acctbal = acctbal + abet
  152. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  153. end
  154.  
  155. if total = nub & total = 6 then
  156. do
  157. abet = bet + bet + bet
  158. acctbal = acctbal + abet
  159. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  160. end
  161.  
  162. if total = nub & total = 8 then
  163. do
  164. abet = bet + bet + bet
  165. acctbal = acctbal + abet
  166. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  167. end
  168.  
  169. if total = nub & total = 9 then
  170. do
  171. abet = bet + bet
  172. acctbal = acctbal + abet
  173. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  174. end
  175.  
  176. if total = nub & total = 10 then
  177. do
  178. abet = bet + bet
  179. acctbal = acctbal + abet
  180. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  181. end
  182.  
  183. if total = nub & total = 11 then
  184. do
  185. abet = bet + bet
  186. acctbal = acctbal + abet
  187. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  188. end
  189.  
  190. if total = nub & total = 12 then
  191. do
  192. abet = bet * 5
  193. acctbal = acctbal + abet
  194. string=" You "||ROD||"WIN"||VIT||" ! "||GRON||abet||VIT ; call output
  195. end
  196.  
  197. if total ~= nub then 
  198. do
  199. string="" ; call output
  200. string=" You "||ROD||"LOOSE"||VIT||" !!!" ; call output
  201. acctbal = acctbal - bet
  202. end
  203.  
  204. string="" ; call output
  205. string="You have now $"||GRON||acctbal||VIT ; call output
  206. if acctbal <= 0 then CALL BYE1
  207. string="" ; call output
  208. call Prompt DoorName,LineNumber,"Roll Again (y/N) ?",2
  209. ans=upper(result)
  210. if ans = "Y" then call START
  211. if ans = "" then call BYE
  212. if ans = " " then call BYE
  213. if ans = "N" then call BYE
  214. Call Bye
  215.  
  216. BEGIN:
  217. string=CLS
  218. call output ; string=VIT
  219. call output ; string="      Welcome to another fine "||GRON||"Active"||VIT||" product."
  220. call output ; string=" "
  221. call output ; string="      Here we present "||CYAN||"CRAPS v3.0"||VIT||" to you"
  222. call output ; string=" "
  223. call output ; string="      Created by : Mikael Johansson [M6005]"
  224. call output ; string=""
  225. call output 
  226. /* CALL PAUSE */
  227. CALL PLAYERFILE
  228. CALL SCOREBOARD
  229. RETURN
  230.  
  231. INSTRUCTION:
  232. string=CLS
  233. call output ; string=VIT
  234. call output ; string="                   Win Table"
  235. call output ; string="                   --- -----"
  236. call output ; string=" "
  237. call output ; string=LILA"             2  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  238. call output ; string=LILA"             3  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  239. call output ; string=LILA"             4  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  240. call output ; string=LILA"             5  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  241. call output ; string=LILA"             6  "||GRON||"Gives you"||CYAN||"  3 "||GUL||"*"||GRON||" Bet "
  242. call output ; string=LILA"             7  "||GRON||"Gives you"||CYAN||" 10 "||GUL||"*"||GRON||" Bet "
  243. call output ; string=LILA"             8  "||GRON||"Gives you"||CYAN||"  3 "||GUL||"*"||GRON||" Bet "
  244. call output ; string=LILA"             9  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  245. call output ; string=LILA"            10  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  246. call output ; string=LILA"            11  "||GRON||"Gives you"||CYAN||"  2 "||GUL||"*"||GRON||" Bet "
  247. call output ; string=LILA"            12  "||GRON||"Gives you"||CYAN||"  5 "||GUL||"*"||GRON||" Bet "
  248. call output ; string=" "
  249. call output
  250. RETURN
  251.  
  252. ROLL:
  253.   ARG n
  254.   x=OPEN(f,'RAM:DUMMY','W')
  255.   IF x=0 THEN CALL QEXIT
  256.   CALL WRITELN(f,'dummy')
  257.   CALL CLOSE(f)
  258.   die1=(WORD(STATEF('RAM:DUMMY'),7)%1)//n+1
  259.   CALL DELAY(28+LEFT(die1,2))
  260.   x=OPEN(f,'RAM:DUMMY','W')
  261.   IF x=0 THEN CALL QEXIT
  262.   CALL WRITELN(f,'dummy')
  263.   CALL CLOSE(f)
  264.   die2=(WORD(STATEF('RAM:DUMMY'),7)%1)//n+1
  265.   string=CR
  266. call output ; string=CYAN"  -------    -------"CR
  267. call output ; string=CYAN"  | "d.1.die1" |    | "d.1.die2" |"CR
  268. call output ; string=CYAN"  | "d.2.die1" |    | "d.2.die2" |"CR
  269. call output ; string=CYAN"  | "d.3.die1" |    | "d.3.die2" |"CR
  270. call output ; string=CYAN"  -------    -------"CR
  271. call output ; string=VIT||CR
  272. call output
  273. RETURN
  274.  
  275. PLAYERFILE:
  276.   string="" ; call output
  277.   string=GUL" Checking player file..." ; call output
  278.   string="" ; call output
  279.   Acctbal = 100
  280.   Flag = 0
  281.   nplayers = 0
  282.  
  283.   if ~exists(playerfile) then signal newfile
  284.  
  285.    call open(file1,playerfile, 'R')
  286.      nplayers = readln(file1)      
  287.      if nplayers = 0 then signal newfile
  288.      do i = 1 to nplayers
  289.         player.i = readln(file1)     
  290.         score.i = readln(file1)      
  291.         if player.i = Uhandle then do  
  292.             Acctbal = score.i         
  293.             if acctbal <= 0 then acctbal = 100
  294.            string=VIT"I see you have bet here before!" ; call output
  295.            string=VIT"Your account balance is:  $"CYAN||Acctbal||VIT ; call output
  296.            string=" "; call output
  297.            Flag = 1                  
  298.         end
  299.      end
  300.    call close(file1)
  301. Newfile:
  302.    if Flag = 0 then do               
  303.        if nplayers < MaxPlayers then do 
  304.          string=VIT"Ah Ha,, another New Player!!" ; call output
  305.          string=VIT"You will be given $100 to start you out!" ; call output
  306.          nplayers = nplayers + 1
  307.          player.nplayers = UHandle
  308.          score.nplayers = Acctbal
  309.          end
  310.        else if nplayers >= MaxPlayers then do
  311.          string="" ; call output
  312.          string="Sorry there is no room for another Craps gambler !!!!!" ; call output
  313.          string="Talk to Sysop maybe he/she can do something about that!" ; call output
  314.          call HotKey DoorName,LineNumber,"Press any key ..."
  315.          CALL BYE
  316.        end
  317.     end
  318. RETURN
  319.  
  320. SCOREBOARD:
  321.   string="" ; call output
  322.   string=" Sorting Scores............." ; call output
  323.   CALL SORTSCORES
  324.   Flag = 1
  325.   i = 1
  326.   j = 1
  327.   More = 'Y'
  328.   Do Forever
  329.      if More ~= 'Y' then break
  330.      Do while Flag = 1
  331.         string="" ; call output
  332.         string=GUL"                    *******************************" ; call output
  333.         string=LILA"                               SCOREBOARD" ; call output
  334.         string=GUL"                    *******************************"||LILA||"" ; call output
  335.         Flag = 0
  336.      end
  337.      if player.j = UHandle then Score.j = AcctBal
  338.      P = Left(Player.j,20,' ')  
  339.      string="                       "P"  $"Score.j  ; call output
  340.      i = i + 1
  341.      j = j + 1
  342.      if j > Nplayers then break
  343.      else if j <= Nplayers & i = 11 then do
  344.          Flag = 1
  345.          i = 0          /* Only display 10 names per page */
  346.          string=GUL"                   *******************************" ; call output
  347.          call Prompt DoorName,LineNumber,GUL"                    Do you want to see more (Y/N)? ",2
  348.          More=result ; more = upper(more) ; more = left(more,1)
  349.          CHECKPANIC more
  350.          iterate
  351.        end
  352.      else if j <= Nplayers & i < 11 then iterate
  353.   end
  354.   if More = 'Y' then string=GUL"                    *******************************" ; call output
  355.   CALL PAUSE
  356. RETURN
  357.  
  358. SORTSCORES:
  359.     if nplayers < 2 then return
  360.     do i = 1 to (Nplayers - 1)
  361.      do j = (i+1) to Nplayers
  362.         if Score.i < Score.j then do
  363.           Temp = Score.i
  364.           Score.i = Score.j
  365.           Score.j = Temp
  366.           Temp = Player.i
  367.           Player.i = Player.j
  368.           Player.j = Temp
  369.         end
  370.      end
  371.   end
  372. RETURN
  373.  
  374. BYE:
  375. string=CLS
  376. call output ; string=VIT
  377. call output ; string=" Thankx for playing "||CYAN||"CRAPS"||VIT||" from "||LILA||"Active Development"||vit
  378. call output ; string=" "
  379. call output ; string=" This Game is created by : Mikael Johansson [M6005]"
  380. call output ; string=" "
  381. call output ; string=" Support and developer board for this game is AnkeBorg"
  382. call output ; string=" FidoNet 2:200/210.0"
  383. call output ; string=" "
  384. call output ; string=CYAN" AnkeBorg  INT +46-42-293375"VIT
  385. call output ; string=" "
  386. call output
  387.     CALL SORTSCORES
  388.     string = "delete >nil: doors:craps/craps.play"
  389.     address command string
  390.     call open(file1,playerfile,'W')
  391.     call writeln(file1,NPlayers)
  392.       do i = 1 to NPlayers
  393.         if player.i = UHandle then Score.i = Acctbal
  394.         call writeln(file1, player.i)
  395.         call writeln(file1, score.i)
  396.       end
  397.     call close(file1)
  398. call HotKey DoorName,LineNumber,"Press Any key to getback to "||bbsname
  399. call Exit_Door DoorName,LineNumber
  400. exit 0
  401.  
  402. BYE1:
  403.     string="" ; call output
  404.     string="  YOU HAVE LOST EVERYTHING YOU HAVE" ; call output
  405.     string="  PLEASE START THIS GAME AGAIN AND" ; call output
  406.     string="  YOU WILL GET ANOTHER 100$" ; call output
  407.     string="" ; call output
  408.     CALL SORTSCORES
  409.     string = "delete >nil: doors:Craps/Craps.play"
  410.     address command string
  411.     call open(file1,playerfile,'W')
  412.     call writeln(file1,NPlayers)
  413.       do i = 1 to NPlayers
  414.         if player.i = UHandle then Score.i = Acctbal
  415.         call writeln(file1, player.i)
  416.         call writeln(file1, score.i)
  417.       end
  418.     call close(file1)
  419. call HotKey DoorName,LineNumber,"Press Any key to getback to "||bbsname
  420. call Exit_Door DoorName,LineNumber
  421. exit 0
  422.  
  423. PAUSE:
  424. string=" " ; call output
  425. call HotKey DoorName,LineNumber,"Press Any key...."
  426. string=" " ; call output
  427. RETURN
  428.  
  429. CHECKPANIC: procedure
  430. RETURN
  431.  
  432. END_IT:
  433. string="Pick a number next time" ; call output
  434. call HotKey DoorName,LineNumber,"Press Any key...."
  435. call Exit_Door DoorName,LineNumber
  436. exit 0
  437.  
  438. QEXIT:
  439. string=" 0 picked number" ; call output
  440. string="Returning to bbs" ; call output
  441. call ERROR
  442.  
  443. /************************************************************************/
  444. /* Routines                                                             */
  445. /************************************************************************/
  446.  
  447. ERROR:
  448. call Exit_Door DoorName,LineNumber
  449. exit 10
  450.  
  451. output:                                  
  452. call message DoorName,LineNumber,string,1
  453. return
  454.